home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _AB12518E6D164E2D9D9FE27064092C09 < prev    next >
Text File  |  2004-12-03  |  870b  |  45 lines

  1. //sample texture, and make a tiny part of it "shine" based on distance froma given point
  2. //Luke Lenhart
  3. //(C)2004-2005 Digipen Institute of Technology
  4.  
  5. //cloud sampler
  6. sampler2D sampTex;
  7.  
  8. //shader input
  9. struct PS_INPUT
  10. {
  11.     float3 Pos : TEXCOORD1;
  12.     float2 Tex0 : TEXCOORD0;
  13.     float4 Color : COLOR;
  14. };
  15.  
  16. //things within a certain distance of this will "shine"
  17. float2 point;
  18.  
  19. //distance from point at which shine occurs
  20. float tarDist;
  21.  
  22. //shader code
  23. float4 PShader(PS_INPUT In) : COLOR
  24. {
  25.     //sample textutes
  26.     float4 texclr=tex2D(sampTex,In.Tex0);
  27.     
  28.     //blend with vert color
  29.     float4 clr=texclr*In.Color;
  30.     
  31.     //calc shiny mod
  32.     float curDist=abs(tarDist-distance(In.Pos.xy,point.xy));
  33.     float mod=1.0f;
  34.     if (curDist<2.0)
  35.     {
  36.         mod=4.0f - curDist*2.0f;
  37.         mod=1.0f + 0.5f*mod;
  38.     }
  39.     
  40.     clr.xyz*=mod;
  41.     
  42.     //spit out color
  43.     return clr;
  44. }
  45.